"""
1、多个文件都需要用前置的时候，可以写入conftest中，可以多个文件调用
2、最外层定义conftest，子文件夹里面需要前置的时候 可以共享

"""
import allure
import pytest
from selenium import webdriver

from utils.get_filepath import get_screen_shot_path
from utils.log_util import logger
from utils.mysql_util import db


@pytest.fixture(scope="session")
def driver_project():
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("http://meikefresh.5istudy.online/")
    print("打开浏览器")
    yield driver
    print("关闭浏览器")
    driver.close()
    driver.quit()


def delete_user(mobile):
    sql = f'DELETE FROM users_userprofile WHERE username = {mobile}'
    db.execute_sql(sql)
    logger.info(f'执行删除用户sql {sql}')


def delete_code(mobile):
    sql = f'DELETE FROM users_verifycode WHERE mobile = {mobile}'
    db.execute_sql(sql)
    logger.info(f'执行删除验证码sql {sql}')

# @pytest.fixture(autouse=True)
# def fixture():
#     print("我是前置步骤")
#     yield "小高"
#     print("我是后置步骤")
